package com.example.canteen.service.impl;

import com.example.canteen.dao.CanteenStatementDao;
import com.example.canteen.dao.impl.CanteenStatementDaoImpl;
import com.example.canteen.domain.CanteenStatement;
import com.example.canteen.service.CanteenStatementService;

import java.util.List;

public class CanteenStatementSerViceImpl implements CanteenStatementService {
    private CanteenStatementDao canteenStatementDao = new CanteenStatementDaoImpl();
    @Override
    public boolean save(CanteenStatement canteenStatement) {
        CanteenStatement c = canteenStatementDao.findById(canteenStatement.getId());
        if(c!=null) {
            return false;
        }
        canteenStatementDao.save(canteenStatement);
        return true;
    }


    @Override
    public CanteenStatement findOne(int id) {
        return canteenStatementDao.findById(id);
    }

    @Override
    public boolean update(CanteenStatement canteenStatement) {
        if(canteenStatementDao.update(canteenStatement)==0) {
            return false;
        }
        return true;
    }

    @Override
    public List<CanteenStatement> findAll() {
        return canteenStatementDao.findAll();
    }

    @Override
    public boolean delete(int id) {
        if (canteenStatementDao.delete(id)==0) {
            return false;
        }
        return true;
    }
}
